package com.api.group.create;

import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.api.test.VoidContextLoader;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.ObjectResultApi;

@ContextConfiguration(loader = VoidContextLoader.class)
public class CreateManyGroups extends AbstractApiTest {

	private String userId;
	private String userPassword;

	private static long groupNumber = 1;

	@BeforeClass
	public void setUpVariables() {

		this.userId = "zyncrofern.a.ndo@gmail.com";
		this.userPassword = "123456";

		getApi().login(userId, userPassword);
	}

	@Test(invocationCount = 255)
	public synchronized void testAddUser() throws ZyncroApiException {

		String name = "GroupoTestProd" + groupNumber;
		String description = null;
		boolean isOpen = false;
		boolean isNewMemberEditor = false;
		boolean isNewMemberTaskManager = false;
		boolean isNewMemberInviter = false;
		boolean isNewMemberOwner = false;
		boolean isNewMemberComment = false;
		boolean showMembers = false;
		String attributes = null;

		try {

			ObjectResultApi<String> result = getApi().getService(IGroupApiService.class).createGroup(name, description, isOpen,
					isNewMemberEditor, isNewMemberTaskManager, isNewMemberInviter, isNewMemberOwner, isNewMemberComment, showMembers,
					attributes);

			logger.info(result);

			logger.info("Group added name '" + name + "'");
		} catch (Exception e) {
			logger.warn(e);
		}
		groupNumber++;
	}
}
